using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using ConfigManager.Core.Instructions;
using NUnit.Framework;

namespace ConfigManager.Tests.Instructions
{
    [TestFixture()]
    public class EmbeddedSectionTests
    {

        [Test()]
        public void RunTest()
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(@"instructions\EmbeddedSection1.xml");
            XmlNode node = xmlDoc.SelectNodes("//comment()")[0];
            string data = "<newNode />";
            EmbeddedSectionInstruction target =
                new EmbeddedSectionInstruction(xmlDoc, node, new Dictionary<string, string>());
            target.Data = data;

            target.Run();

            Assert.IsNotNull(xmlDoc.SelectSingleNode("/root/newNode"), "Embedded Section Instruction was not processed");
            Assert.AreEqual(0, xmlDoc.SelectNodes("//comment()").Count, "Embedded Section Instruction was not removed.");
        }
    }
}
